﻿using System;
using Zeus.Thunder.Core;

namespace SharpTrainer.Delegates
{
  delegate void DoubleOp2(double value);

  class MulticastDelegate : ITestCase
  {
    public void Run()
    {
      DoubleOp2 operations = new DoubleOp2(MathsOperations.MultiplyByTwo2);
      operations += new DoubleOp2(MathsOperations.Square2);

      ProcessAndDisplayNumber(operations, 2.0);
      ProcessAndDisplayNumber(operations, 5.5);
      ProcessAndDisplayNumber(operations, 8.6);
      Console.WriteLine();
      Console.ReadLine();
    }

    static void ProcessAndDisplayNumber(DoubleOp2 action, double value)
    {
      Console.WriteLine("\nProcessAndDisplayNumber called with value = " + value);
      action(value);
    }
  }
}
